#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    int ret;

    ret = access(argv[1], F_OK);
    if(-1 == ret){
        printf("%s: file does not exist.\n", argv[1]);
        exit(-1);
    }

    ret = access(argv[1], R_OK);
    if(!ret)
        printf("Read permission: Yes\n");
    else
        printf("Read permission: NO\n");
    
    ret = access(argv[1], W_OK);
    if(!ret)
        printf("Write permission: Yes\n");
    else
        printf("Write permission: NO\n");
    
    ret = access(argv[1], X_OK);
    if(!ret)
        printf("Execution permission: Yes\n");
    else
        printf("Execution permission: NO\n");

    exit(0);
}